#include <iostream>
#include <unistd.h>
#include <ctime>
#include "../logs/log.h"

void testLog()
{
    // Log::Logger::ptr logger = Log::LoggerManager::getInstance().getLogger("异步日志1");
    // std::string str = "用来测试异步日志器是否出错-";
    // logger->DEBUG("%s", str.c_str());
    // logger->INFO("%s", str.c_str());
    // logger->WARNNING("%s", str.c_str());
    // logger->ERROR("%s", str.c_str());
    // logger->FATAL("%s", str.c_str());    
    // size_t cursize = 0;
    // size_t count = 0;
    // while (count < 500000)
    // {
    //     std::string tmp = str + std::to_string(count++);
    //     logger->FATAL("%s", tmp.c_str());
    // }

   
    std::string str = "用来测试异步日志器是否出错-";
    LOGDEBUG("%s", str.c_str());
    LOGINFO("%s", str.c_str());
    LOGWARNNING("%s", str.c_str());
    LOGERROR("%s", str.c_str());
    LOGFATAL("%s", str.c_str());    
    size_t cursize = 0;
    size_t count = 0;
    while (count < 500000)
    {
        std::string tmp = str + std::to_string(count++);
        LOGFATAL("%s", tmp.c_str());
    }
}

int main()
{
    // Log::LogSink::ptr stdout_lsp = Log::SinkFactory::create<Log::StdoutLogSink>();
    // Log::LogSink::ptr file_lsp = Log::SinkFactory::create<Log::FileLogSink>("./logfile/test1.log");
    // Log::LogSink::ptr rollSize_lsp = Log::SinkFactory::create<Log::RollByFileSizeLogSink>("./logfile/rollsize-", 1024 * 1024);
    // Log::LogSink::ptr rollTime_lsp = Log::SinkFactory::create<Log::RollByFileTimeLogSink>("./logfile/rolltime-",Log::TimeGap::GAP_MINUTE);
    // std::vector<Log::LogSink::ptr> sinks = {stdout_lsp, file_lsp, rollSize_lsp, rollTime_lsp};
    // Log::Logger::ptr logger(new Log::SyncLogger("日志器1", Log::LogLevel::value::INFO, sinks, Log::Formatter::ptr(new Log::Formatter)));

    // std::unique_ptr<Log::LoggerBuilder> builder(new Log::GlobalLoggerBuilder());    //实例化一个全局日志器的建造者
    // builder->buildLoggerType(Log::LoggerType::LOGGER_ASYNC);
    // //builder->buildEnableDynamicAsync(Log::BufferType::DYNAMICGROW);
    // builder->buildLoggerName("异步日志1");
    // builder->buildLimitLevel(Log::LogLevel::value::INFO);
    // builder->buildFormatter("[%d{%Y-%m-%d %H:%M:%S}][%t][%f: %l]:[%p]%T[%c]%T%m%n");
    // builder->buildSinks<Log::StdoutLogSink>();
    // builder->buildSinks<Log::FileLogSink>("./logfile/test1.log");
    // builder->buildSinks<Log::RollByFileSizeLogSink>("./logfile/rollsize-", 1024 * 1024);
    // builder->buildSinks<Log::RollByFileTimeLogSink>("./logfile/rolltime-", Log::TimeGap::GAP_MINUTE);
    // Log::Logger::ptr logger = builder->build();
    testLog();

    return 0;
}


